
package com.shop.cloud.mall.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.log.annotation.SysLog;
import com.shop.cloud.mall.admin.service.VipUserRechargeService;
import com.shop.cloud.mall.common.entity.VipUserRecharge;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 用户会员充值
 *
 * @author
 * @date 2024-03-19 15:18:41
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/vipuserrecharge")
@Tag(description = "vipuserrecharge", name = "用户会员充值管理")
public class VipUserRechargeController {

    private final VipUserRechargeService vipUserRechargeService;

    /**
     * 用户会员充值分页列表
     * @param page 分页对象
     * @param vipUserRecharge 用户会员充值
     * @return
     */
    @Operation(summary = "用户会员充值分页列表")
    @GetMapping("/page")
    @PreAuthorize("@ato.hasAuthority('mall:vipuserrecharge:index')")
    public R getPage(Page page, VipUserRecharge vipUserRecharge) {
        return R.ok(vipUserRechargeService.page2(page, vipUserRecharge));
    }

    /**
     * 用户会员充值查询
     * @param id
     * @return R
     */
    @Operation(summary = "用户会员充值查询")
    @GetMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:vipuserrecharge:get')")
    public R getById(@PathVariable("id") String id) {
        return R.ok(vipUserRechargeService.getById(id));
    }

    /**
     * 用户会员充值新增
     * @param vipUserRecharge 用户会员充值
     * @return R
     */
    @Operation(summary = "用户会员充值新增")
    @SysLog("新增用户会员充值")
    @PostMapping
    @PreAuthorize("@ato.hasAuthority('mall:vipuserrecharge:add')")
    public R save(@RequestBody VipUserRecharge vipUserRecharge) {
        return R.ok(vipUserRechargeService.save(vipUserRecharge));
    }

    /**
     * 用户会员充值修改
     * @param vipUserRecharge 用户会员充值
     * @return R
     */
    @Operation(summary = "用户会员充值修改")
    @SysLog("修改用户会员充值")
    @PutMapping
    @PreAuthorize("@ato.hasAuthority('mall:vipuserrecharge:edit')")
    public R updateById(@RequestBody VipUserRecharge vipUserRecharge) {
        return R.ok(vipUserRechargeService.updateById(vipUserRecharge));
    }

    /**
     * 用户会员充值删除
     * @param id
     * @return R
     */
    @Operation(summary = "用户会员充值删除")
    @SysLog("删除用户会员充值")
    @DeleteMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:vipuserrecharge:del')")
    public R removeById(@PathVariable String id) {
        return R.ok(vipUserRechargeService.removeById(id));
    }

}
